#include "GY_GraphicsButtonEditItem.h"
#include <QDebug>
#include <QCursor>
#include <QMouseEvent>
#include <QPainter>

GY_GraphicsButtonEditItem::GY_GraphicsButtonEditItem(QGraphicsItem *parent) : QGraphicsPathItem(parent)
{
    //鼠标样式
    setCursor(QCursor(Qt::CrossCursor));
    setAcceptHoverEvents(true);
    setFlags(QGraphicsItem::ItemIsMovable|QGraphicsItem::ItemIsSelectable|QGraphicsItem::ItemIsFocusable);
    QPen pen;
    pen.setColor(Qt::red);
    pen.setStyle(Qt::DotLine);
    this->setPen(pen);
}

void GY_GraphicsButtonEditItem::mouseDoubleClickEvent(QGraphicsSceneMouseEvent *event)
{
    if(event->button() == Qt::LeftButton)
    {
        emit doubleClicked();
    }
}

void GY_GraphicsButtonEditItem::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget)
{
    painter->setPen(this->pen());
    painter->drawPath(this->path());
    QGraphicsPathItem::paint(painter,option,widget);
}

